home *** CD-ROM | disk | FTP | other *** search
/ Inside Mac Games Volume 2 October / IMG Oct-94.toast / Demos / Outland Installer / Outland Installer / AT&T DataPort < prev    next >
Text File  |  1993-03-20  |  6KB  |  259 lines

  1. ! "AT&T DataPort Modem - 3/20/93"
  2. ! Written by George Warner
  3. ! warnergt@aloft.att.com
  4. ! It works for me, I hope it works for you.
  5. ! After much experimenting, it seems 100% to me.
  6. @ORIGINATE
  7. @ANSWER
  8. !
  9. @LABEL 1
  10. note "Resetting serial port." 2
  11. serreset 19200, 0, 8, 1
  12. note "Syncing the modem." 2
  13. ! first sync up the modem
  14. matchclr
  15. matchstr 1 4 "OK\13\10"
  16. settries 0
  17. @LABEL 2
  18. write "AT\13"
  19. matchread 30
  20. inctries
  21. iftries 4 59
  22. jump 2
  23. @LABEL 3
  24. !
  25. !    Now, recall the modems factory configuration
  26. @LABEL 4
  27. note "Modem synchronized.  Setting up." 2
  28. matchstr 1 6 "OK\13\10"
  29. ! Factory default options, disable echo, ignore DTR
  30. ! Disable error control, disable data compression; ARA handles this
  31. write "AT&F0E0&D0\\N0%C0\13"
  32. matchread 30
  33. inctries
  34. iftries 2 59
  35. ! Modem is not responding, reset
  36. DTRClear
  37. pause 5
  38. DTRSet
  39. jump 4
  40. !
  41. @LABEL 6
  42. ! Set RTS/CTS handshaking ON in the serial port (CTS is the 2nd 1 in the
  43. ! HSReset command below, and RTS is the 6th 1 in the HSReset command below).
  44. HSReset 0 1 0 0 0 1 
  45. !
  46. ! Did the user turn on the speaker flag?
  47. ifstr 2 8 "1"
  48. @LABEL 7
  49. pause 5
  50. matchstr 1 8 "OK\13\10"
  51. write "ATM0\13"
  52. matchread 30
  53. jump 59
  54. !
  55. ! The modem is ready.  So enable answering, or originate a call
  56. !
  57. @LABEL 8
  58. ifANSWER 30
  59. note "Dialing ^1" 2
  60. write "ATS0=0DT^1\13"
  61. !
  62. @LABEL 9
  63. matchstr 1 10 "CONNECT 300\13\10"
  64. matchstr 2 11 "CONNECT 1200\13\10"
  65. matchstr 3 12 "CONNECT 2400\13\10"
  66. matchstr 4 14 "CONNECT 4800\13\10"
  67. matchstr 5 15 "CONNECT 7200\13\10"
  68. matchstr 6 16 "CONNECT 9600\13\10"
  69. matchstr 7 17 "CONNECT 12000\13\10"
  70. matchstr 8 18 "CONNECT 14400\13\10"
  71. matchstr 9 50 "NO CARRIER\13\10"
  72. matchstr 10 50 "ERROR\13\10"
  73. matchstr 11 52 "NO DIALTONE\13\10"
  74. matchstr 12 53 "BUSY\13\10"
  75. matchstr 13 54 "NO ANSWER\13\10"
  76. matchread 700
  77. jump 59
  78. !
  79. @LABEL 10
  80. note "Communicating at 300 bps." 2
  81. COMMUNICATINGAT 300
  82. jump 19
  83. !
  84. @LABEL 11
  85. note "Communicating at 1200 bps." 2
  86. COMMUNICATINGAT 1200
  87. jump 19
  88. !
  89. @LABEL 12
  90. note "Communicating at 2400 bps." 2
  91. COMMUNICATINGAT 2400
  92. jump 19
  93. !
  94. @LABEL 14
  95. note "Communicating at 4800 bps." 2
  96. COMMUNICATINGAT 4800
  97. jump 19
  98. !
  99. @LABEL 15
  100. note "Communicating at 7200 bps." 2
  101. COMMUNICATINGAT 7200
  102. jump 19
  103. !
  104. @LABEL 16
  105. note "Communicating at 9600 bps." 2
  106. COMMUNICATINGAT 9600
  107. jump 19
  108. !
  109. @LABEL 17
  110. note "Communicating at 12000 bps." 2
  111. COMMUNICATINGAT 12000
  112. !
  113. @LABEL 18
  114. note "Communicating at 14400 bps." 2
  115. COMMUNICATINGAT 14400
  116. !
  117. @LABEL 19
  118. ! If the script is answering a telephone call, just exit right away.
  119. ifANSWER 20
  120. ! give the other end some time (3 seconds)
  121. pause 30
  122. @LABEL 20
  123. ! Exit successfully.
  124. exit 0
  125. !
  126. ! @ANSWER
  127. ! Set up the modem to answer
  128. @LABEL 30
  129. note "Waiting for incoming call..." 2
  130. matchclr
  131. matchstr 1 31 "OK\13\10"
  132. write "ATS0=1\13"
  133. matchread 30
  134. jump 59
  135. !
  136. @LABEL 31
  137. matchstr 1  32 "RING\13\10"
  138. matchstr 2  11 "CONNECT 1200\13\10"
  139. matchstr 3  12 "CONNECT 2400\13\10"
  140. matchstr 4  14 "CONNECT 4800\13\10"
  141. matchstr 5  15 "CONNECT 7200\13\10"
  142. matchstr 6  16 "CONNECT 9600\13\10"
  143. matchstr 7  17 "CONNECT 12000\13\10"
  144. matchstr 8  18 "CONNECT 14400\13\10"
  145. matchstr 9  50 "NO CARRIER\13\10"
  146. matchstr 10 59 "ERROR\13\10"
  147. matchstr 11 52 "NO DIALTONE\13\10"
  148. matchstr 12 53 "BUSY\13\10"
  149. matchstr 13 54 "NO ANSWER\13\10"
  150. matchread 700
  151. jump 31
  152. !
  153. @LABEL 32
  154. !
  155. !  What is userhook 1 ?  Here's the idea:  Either this script 
  156. !  controls a server that is waiting to answer the telephone, or it's waiting 
  157. !  for a callback to a connection that was initiated.  AppleTalk Remote Access 
  158. !  does a "passive" listen on the serial port (via the Serial Port Arbitrator) 
  159. !  so that other communications applications can use the serial port when ARA 
  160. !  is not using it.  When a call comes in for a server or callback, there
  161. !  will be about 5-14 seconds while the modems negotiate the connection.
  162. !  What would happen if a communications application on this Macintosh 
  163. !  wanted to use the serial port during that time?  Both connections
  164. !  would fail.  The userhook 1 command tells ARA to mark the serial port in 
  165. !  use.  When that happens, applications that want to use the serial port will 
  166. !  be told it's busy, and the incoming connection can complete.  With that in 
  167. !  mind, the strategy below is:  When the modem receives a ring, jump to label 
  168. !  32, issue the userhook 1 command, then jump back up to label 31, wait for 
  169. !  the connect result code and continue processing the script.
  170. !
  171. userhook 1
  172. note "Answering phone..." 2
  173. jump 31
  174. !
  175. ! 50: error messages
  176. !
  177. @LABEL 50
  178. ! No carrier.
  179. exit -6021
  180. !
  181. @LABEL 52
  182. ! No dial tone.
  183. exit -6020
  184. !
  185. @LABEL 53
  186. ! Busy
  187. exit -6022
  188. !
  189. @LABEL 54
  190. ! No answer.
  191. exit -6023
  192. !
  193. @LABEL 59
  194. ! Modem error.
  195. exit -6019
  196. !
  197. ! Hang up the modem
  198. !
  199. @HANGUP
  200. @LABEL 60
  201. settries 0
  202. @LABEL 61
  203. matchclr
  204. matchstr 1 63 "OK\13\10"
  205. matchstr 2 63 "NO CARRIER\13\10"
  206. matchstr 3 63 "ERROR\13\10"
  207. write "ATH\13"
  208. matchread 30
  209. inctries
  210. iftries 3 63
  211. ! no response, try escape sequence
  212. matchclr
  213. matchstr 1 62 "OK\13\10"
  214. pause 20
  215. write "+++"
  216. matchread 40
  217. !
  218. ! No response from modem, toggle DTR
  219. !
  220. DTRClear
  221. pause 5
  222. DTRSet
  223. pause 5
  224. jump 61
  225. !
  226. @LABEL 62
  227. pause 5
  228. matchclr
  229. matchstr 1 63 "OK\13\10"
  230. matchstr 2 63 "NO CARRIER\13\10"
  231. matchstr 3 63 "ERROR\13\10"
  232. write "ATH\13"
  233. matchread 70
  234. jump 61
  235. !
  236. ! Recall factory settings
  237. !
  238. @LABEL 63
  239. pause 5
  240. matchclr
  241. matchstr 1 64 "OK\13\10"
  242. ! Factory default options, disable echo, ignore DTR
  243. ! Disable error control, disable data compression; ARA handles this
  244. write "AT&F0E0&D0\\N0%C0\13"
  245. matchread 30
  246. !
  247. ! Turn off auto answer
  248. @LABEL 64
  249. pause 5
  250. write "ATS0=0\13"
  251. matchstr 1 65 "OK\13\10"
  252. matchread 30
  253. !
  254. ! Add delay to make sure other side of connection hangs up for call back.
  255. !
  256. @LABEL 65
  257. pause 5
  258. exit 0
  259.